package org.mspring.mlog.action.admin;

import org.mspring.mlog.entity.User;
import org.mspring.mlog.security.SecurityService;
import org.mspring.mlog.security.service.TreeItemService;
import org.mspring.nbee.utils.RequestUtils;
import org.mspring.nbee.web.Action;
import org.mspring.nbee.web.view.json.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Gao Youbo
 * @since 2014年10月24日
 */
@Action
@RequestMapping("/admin")
public class MenuAction extends BaseAdminAction {
    private SecurityService securityService;
    private TreeItemService treeItemService;

    @RequestMapping("/tabs")
    @Json
    public Object tabs2(HttpServletRequest request, HttpServletResponse response) {
        String id = RequestUtils.getRequiredParam(request, "id");
        User user = securityService.getCurrentUser(request);
        return treeItemService.listTabByUser(id, user.getId());
    }

    @Autowired
    public void setSecurityService(SecurityService securityService) {
        this.securityService = securityService;
    }

    @Autowired
    public void setTreeItemService(TreeItemService treeItemService) {
        this.treeItemService = treeItemService;
    }

}
